package conn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.junit.Test;
/**
 * 链接数据库
 * @author Administrator
 *
 */

public class Cont {
	
	Connection conn=null;
	
	public Connection getConnection() throws ClassNotFoundException, SQLException{
		Class.forName("com.mysql.jdbc.Driver");
		String url="jdbc:mysql://localhost:3306/exam?useUnicode=true&characterEncoding=utf-8";
		String username="root";
		String userpwd="123456";
		conn=DriverManager.getConnection(url,username,userpwd);
		System.out.println("s");
		
		return conn;
		
	}

	/**
	 * 释放链接
	 * @throws SQLException 
	 */
	public void closeconn() throws SQLException{
		conn.close();
	}

}
